<script type="text/javascript" language="javascript">
    (function($) {
        /*whatever jQuery stuff*/
        $(function(){					
            $("#Form").validate({
                rules: {
					cat_at: "required",				
                    score: {
						digits : true,
						required : true
					}
                },
                showErrors: function(errorMap, errorList){
                    var messages='';
                    for (var i = 0; i < errorList.length; i++) {					
                        messages += '- '+errorList[i].message+'\n';
                    }
                    if(messages) alert("<?php echo lang('requirement');?>: \n"+"¯¯¯¯¯¯¯¯¯¯ \n"+ messages);
                    //this.defaultShowErrors();
                } ,
                submitHandler: function(e){
					$('.ajax-loading',e).css('visibility','visible');
					form.submit();
                },
                onfocusout: false,
                onkeyup: false,
				onclick: false,					
                messages: {
					cat_at: "<?php echo lang('cat_at');?>",				
                    score: {
						required : "<?php echo lang('score');?>"
					}				
                }
            });	
			
			//Load Score interval 1 second
			setInterval(function(){
				$.ajax({
					type:'post',
					url:'<?php echo get_url(2);?>/ajax_load_score',
					dataType:'json'
				}).done(function(data){	
					for(var i=1;i<=10;i++){
						$('ul.cat_'+('0'+i).substr(-2)+' div.score').each(function(keys,items){
							var newScore = addCommas(eval('data.cat'+('0'+i).substr(-2)+'_'+(keys+1)));
							if(newScore != $(this).html()){
								$(this).prev().animate({'opacity': '0.5'},500,function(){
									$(this).animate({'opacity': '1'},500);
									$(items).html(newScore);
								});
							}
						});						
					}
				});
			},1000);	
        });
    })(jQuery);
</script>
<div class="wrap">
 	<div id="icon-index" class="icon32"><br /></div><h2><?php echo ucwords(str_replace('_',' ',$this->uri->segment(1)));?> &raquo; <?php echo ucwords(str_replace('_',' ',$this->uri->segment(2)));?></h2>
</div>
<div id="wpbody-content">
    <div class="metabox-holder" id="dashboard-widgets">
            <div class="inside">
				<div style="width:908px;">
				<?php for($i=1;$i<=12;$i++):?>
				<ul class="cat_<?php echo sprintf('%02d',$i);?>" style="position:relative;width:100%;overflow:hidden;clear:both;padding:0;margin:0;">
					<li style="position:relative;float:left;width:25px;"><h2><?php echo sprintf('%02d',$i);?></h2></li>
					<?php for($j=1;$j<=6;$j++):?>
					<li style="position:relative;float:left;width:140px;margin-left:5px;text-align:center;border:1px solid #dcd9d8;">
						<div style="padding:5px 0;background-color:#65615a;color:#FFFFFF;"><?php echo ${'dataXML'.sprintf('%02d',$i).$j}->left_title;?></div>
						<div class="score"><?php echo number_format($dataResult->{'cat'.sprintf('%02d',$i).'_'.$j});?></div>
					</li>
					<?php endfor;?>	
				</ul>
				<?php endfor;?>
				</div>
				<div class="wrap">
					<h2><?php echo lang('score_update');?></h2>
				</div>
				<form name="Form" action="<?php echo current_url();?>/update" method="post" id="Form" novalidate="novalidate">
					<table cellspacing="0" cellpadding="0" border="0" class="form-table">
						<tbody>					
						<tr>
							<th scope="row"><?php echo lang('cat_at');?></th>
							<td>
								<select name="cat_at" id="cat_at">
									<option value=""><?php echo lang('select_option');?></option>
									<?php for($i=1;$i<=12;$i++):?>
										<optgroup label="<?php echo sprintf('%02d',$i);?>">
										<?php for($j=1;$j<=6;$j++):?>
											<option value="<?php echo "cat".sprintf('%02d',$i)."_".$j;?>" style="padding:2px 10px;"><?php echo ${'dataXML'.sprintf('%02d',$i).$j}->left_title;?></option>
										<?php endfor;?>
										</optgroup>
									<?php endfor;?>
								</select>
							</td>
						</tr>
						<tr>
							<th scope="row"><?php echo lang('score');?></th>
							<td><input type="text" name="score" id="score" class="medium-text"/></td>
						</tr>						
						<tr>
							<th scope="row">&nbsp;</th>
							<td><p class="submit"><input type="submit" class="button-primary" value="<?php echo lang('button_update');?>">&nbsp;<img src="<?php echo css_asset_url('images/wpspin_light.gif'); ?>" class="ajax-loading" alt=""></p></td>
						</tr>								
						</tbody>
					</table>
					<div class="tablenav bottom"></div>
				</form>
            </div><!-- wpbody inside -->
    </div><!-- wpcontent -->
</div><!-- wpbody-content -->